package com.example.mvvm.activity;

import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.view.KeyEvent;

import androidx.annotation.Nullable;

import com.example.mvvm.R;

import java.util.concurrent.TimeUnit;

import io.reactivex.rxjava3.core.Observable;
import io.reactivex.rxjava3.disposables.Disposable;

/**
 * Time: 4/26/2021 14:18
 * Author: TAO
 * Description:
 */
public class LauncherActivity extends Activity {

    private Disposable subscribe;

    @Override
    protected void onCreate(@Nullable Bundle savedInstanceState) {
        setTheme(R.style.AppTheme_launcher);
        super.onCreate(savedInstanceState);
        subscribe = Observable.timer(1, TimeUnit.SECONDS).subscribe(aLong -> {
            startActivity(new Intent(this, MainActivity.class));
            finish();
            subscribe.dispose();
        });
    }

    @Override
    public boolean onKeyDown(int keyCode, KeyEvent event) {
        // 禁用返回键
        if (keyCode == KeyEvent.KEYCODE_BACK) {
            return true;
        }
        return super.onKeyDown(keyCode, event);
    }
}
